Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Oct 25, 2025

No description provided.

- `{x, ...}.RD = {x.rd, ...}.RD`
- `{x.rd, ...} <: {x, ...}`

## Separation Checking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we dropping all these descriptions on separation checking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are in a separate file: separation-checking.md

@bracevac bracevac self-requested a review October 27, 2025 18:05
**Restriction:** A non-mutable type cannot be downcast by a pattern match to a mutable type. (Note: This is currently not enforced)

**Definition:** A class is _read_only_ if the following conditions are met:
**Definition:** A parent class constructor is _read-only_ if the following conditions are met:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to make sense of this restriction: does it mean that if you decide to mark a class as mutation-tracked, then all exclusive capability from this class must also be tracked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. Because when we widen the type to something that does not extend Mutable, we make the capture set read-only.

When we create an instance of a mutable type we always add `cap` to its capture set. For instance, if class `Ref` is declared as shown previously then `new Ref(1)` has type `Ref[Int]^`.

**Restriction:** A non-mutable type cannot be downcast by a pattern match to a mutable type.
**Restriction:** A non-mutable type cannot be downcast by a pattern match to a mutable type. (Note: This is currently not enforced)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a bit about this and was wondering whether we can do this by inspecting capture sets in the pattern: one may never "widen" a readonly set to a exclusive one since that will be a permission upgrade.

So instead of preventing narrowing we prevent widening, very much like what we are already doing for capture sets.

@odersky odersky force-pushed the implement-mutable-inheritance branch from f4b401e to 97a2ef2 Compare October 28, 2025 10:40
@odersky odersky merged commit 66b14d3 into scala:main Oct 28, 2025
51 checks passed
@odersky odersky deleted the implement-mutable-inheritance branch October 28, 2025 13:47
@WojciechMazur WojciechMazur added this to the 3.8.0 milestone Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants